package screens 
{
	import Entities.InstrumentMC;
	import flash.display.DisplayObject;
	import flash.display.MovieClip;
	import Entities.InstrumentLayer;
	import flash.geom.ColorTransform;
	import flash.geom.Rectangle;
	import flash.display.Sprite;
	/**
	 * ...
	 * @author Andy Wolff
	 */
	public class InstrumentsTab extends MovieClip
	{
		[Embed(source = '../images/Buttons/tabs3.png')] private var tab3IMG:Class;
		private var canvas:NoteCanvas;
		public var instrumentMCs:Array;
		
		public function InstrumentsTab(canvas:NoteCanvas) 
		{
			this.canvas = canvas;
			
			addChild(new tab3IMG());
			
			instrumentMCs = new Array();
			
			var instruments:Array = canvas.getInstruments();
			var lastmc:InstrumentMC = null;
			for each (var IL:InstrumentLayer in instruments) {
				var mc:InstrumentMC = new InstrumentMC(canvas, this, instruments.indexOf(IL,0));
				mc.x = 20;
				mc.y = 40;
				if (lastmc != null) mc.y = lastmc.y + lastmc.height + 20;
				addChild(mc);
				instrumentMCs.push(mc);
				lastmc = mc;
			}
		}
		
		public function refresh():void {
			while (numChildren > 1) removeChild(getChildAt(1));
			var lastmc:InstrumentMC = null;
			for each (var mc:InstrumentMC in instrumentMCs) {
				addChild(mc);
				mc.x = 20;
				mc.y = 40;
				if (lastmc != null) mc.y = lastmc.y + lastmc.height + 20;
				lastmc = mc;
			}
		}
		
		public function restart():void {
			while (numChildren > 1) removeChild(getChildAt(1));
			instrumentMCs = new Array();
			
			var instruments:Array = canvas.getInstruments();
			var lastmc:InstrumentMC = null;
			for each (var IL:InstrumentLayer in instruments) {
				var mc:InstrumentMC = new InstrumentMC(canvas, this, instruments.indexOf(IL,0));
				mc.x = 20;
				mc.y = 40;
				if (lastmc != null) mc.y = lastmc.y + lastmc.height + 20;
				addChild(mc);
				instrumentMCs.push(mc);
				lastmc = mc;
			}
		}
		
	}

}